package com.genexususa.eo.bing.data.wsSubclasses;

import com.genexususa.eo.bing.data.GxItemException;
import org.w3c.dom.Element;
import org.w3c.dom.Node;

public class GxTargetIdToCampaignIdAssociation {
    private long gxTargetId;
    private long targetId;
    private long gxCampaignId;
    private long campaignId;

    public GxTargetIdToCampaignIdAssociation(Element element) throws IllegalArgumentException, GxItemException {
        if (element.getElementsByTagName("GxTargetId").getLength() > 0 &&
            element.getElementsByTagName("GxTargetId").item(0).getChildNodes().getLength() > 0 &&
            Long.valueOf(((Node)element.getElementsByTagName("GxTargetId").item(0).getChildNodes().item(0)).getNodeValue()) != 0) {
            this.gxTargetId = Long.valueOf(((Node)element.getElementsByTagName("GxTargetId").item(0).getChildNodes().item(0)).getNodeValue());
        } else {
            throw new GxItemException("Missing external Target id");
        }
        if (element.getElementsByTagName("BingTargetId").getLength() > 0 &&
            element.getElementsByTagName("BingTargetId").item(0).getChildNodes().getLength() > 0 &&
            Long.valueOf(((Node)element.getElementsByTagName("BingTargetId").item(0).getChildNodes().item(0)).getNodeValue()) != 0) {
            this.targetId = Long.valueOf(((Node) element.getElementsByTagName("BingTargetId").item(0).getChildNodes().item(0)).getNodeValue());
        }
        if (element.getElementsByTagName("GxCampaignId").getLength() > 0 &&
            element.getElementsByTagName("GxCampaignId").item(0).getChildNodes().getLength() > 0 &&
            Long.valueOf(((Node)element.getElementsByTagName("GxCampaignId").item(0).getChildNodes().item(0)).getNodeValue()) != 0) {
            this.gxCampaignId = Long.valueOf(((Node)element.getElementsByTagName("GxCampaignId").item(0).getChildNodes().item(0)).getNodeValue());
        } else {
            throw new GxItemException("Missing external Campaign id");
        }
        if (element.getElementsByTagName("BingCampaignId").getLength() > 0 &&
            element.getElementsByTagName("BingCampaignId").item(0).getChildNodes().getLength() > 0 &&
            Long.valueOf(((Node)element.getElementsByTagName("BingCampaignId").item(0).getChildNodes().item(0)).getNodeValue()) != 0) {
            this.campaignId = Long.valueOf(((Node) element.getElementsByTagName("BingCampaignId").item(0).getChildNodes().item(0)).getNodeValue());
        }
    }

    public long getGxTargetId() {
        return gxTargetId;
    }

    public void setGxTargetId(long gxTargetId) {
        this.gxTargetId = gxTargetId;
    }

    public long getTargetId() {
        return targetId;
    }

    public void setTargetId(long targetId) {
        this.targetId = targetId;
    }

    public long getGxCampaignId() {
        return gxCampaignId;
    }

    public void setGxCampaignId(long gxCampaignId) {
        this.gxCampaignId = gxCampaignId;
    }

    public long getCampaignId() {
        return campaignId;
    }

    public void setCampaignId(long campaignId) {
        this.campaignId = campaignId;
    }
}
